Il n’est pas possible d’introduire un rAmCharts dans un shiny. L’erreur suivante apparaît : impossible de trouver la fonction “controlShinyPlot”…
tab <- tab_moyenne(grandile,"PCS","AGE")
#Fonction pour calculer la variation inter-groupe sur la quanti
inter <- sum(tab$Contrib_inter)
format_box(inter)
#> [1] "211,6"#Visualisation de l'échantillon
taille_echant <- 1000
a <- grandile %>%
sample_n(taille_echant) %>%
select(1,5,9,10,11)
DT::datatable(a)
# #' simul_moyenne
# #'
# #' Fonction qui simule une série d'estimations d'indicateurs
# #' à l'aide de la moyenne empirique
# #'
# #' @param data un dataframe
# #' @param var une variable quantitative
# #' @param taille_echant taille de l'échantillon tiré
# #' @param nbr_simul nombre de tirage d'échantillons
# #'
# #' @return un vecteur numérique
# #' @export
# #'
# #' @examples simul_moyenne(grandile,"AGE",1000,1000)
# simul_moyenne <- function(data,var,taille_echant,nbr_simul){
# replicate(nbr_simul, {
# a <- data %>% sample_n(taille_echant)
# b <- mean(a[,var])
# b
# })
# }
#
# #' histoplotly_simul
# #'
# #' Histogramme de la simulation d'estimation avec la moyenne empirique
# #'
# #' @param serie un vecteur numérique
# #' @param var une variable quantitative
# #'
# #' @return un graphique GGPLOT2
# #' @export
# #'
# #' @examples
# #' a <- simul_moyenne(grandile,"AGE",1000,1000)
# #' histoplotly_simul(a,"AGE")
# histoplotly_simul <- function(serie,var){
# a <- serie %>% as.data.frame() %>% rename({{var}} := ".")
# ggplot(a) + aes(.data[[var]])+geom_histogram()
#
# }
dt <- grandile %>% mutate(PAUVRE = ifelse(PAUVRE == "1",TRUE,FALSE))
a <- simul_moyenne(dt,"PAUVRE",1000,1000)*100
histoplotly_simul(a,"PAUVRE")
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.b <- simul_moyenne(dt,"AGE",1000,1000)
histoplotly_simul(b,"AGE")
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.c <- simul_moyenne(dt,"REV_DISPONIBLE",1000,1000)
histoplotly_simul(c,"REV_DISPONIBLE")
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.d <- simul_moyenne(dt,"PATRIMOINE",1000,1000)
histoplotly_simul(d,"PATRIMOINE")
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.